package com.athu.study.config;

import dev.langchain4j.data.embedding.Embedding;
import dev.langchain4j.data.segment.TextSegment;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.embedding.EmbeddingModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.model.openai.OpenAiEmbeddingModel;
import dev.langchain4j.store.embedding.EmbeddingStore;
import dev.langchain4j.store.embedding.qdrant.QdrantEmbeddingStore;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.swing.text.Segment;

@Configuration
public class LLMConfig {
    @Bean
    public EmbeddingModel embeddingModel() {
        return OpenAiEmbeddingModel.builder().
                apiKey(System.getenv("aliQwen-api")).
                modelName("text-embedding-v3").
                baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1").build();
    }
    @Bean
    public QdrantClient qdrantClient(){
        QdrantGrpcClient client = QdrantGrpcClient.
                newBuilder("192.168.6.100", 6334, false).build();
        return new QdrantClient(client);
    }
    @Bean
    public EmbeddingStore<TextSegment> embeddingStore(){
        return QdrantEmbeddingStore.builder().
                host("192.168.6.100").
                port(6334).
                collectionName("test-qdrant").build();
    }
}
